﻿/*
   Advanced Flash Engine in ActionScript 3.
   Copyright (C) 2009  Dean Gardiner, Taylor Lodge

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.winmastergames.lolgame.powerups {
	import com.winmastergames.lolgame.mapDefault;
	import flash.display.*;
	import flash.events.*;
	import flash.utils.Timer;
	import com.winmastergames.lolgame.engine;

	public class base extends MovieClip {
		//public var myMC:MovieClip;
		public var Mstage:mapDefault;
		public var deathTimer:Timer = new Timer(15000);
		public var killed:Boolean = false;

		public function base(xLoc:Number, yLoc:Number, stageRef:mapDefault){
			deathTimer.addEventListener(TimerEvent.TIMER, deletePowerup);
			stageRef.powerups.addChild(this);
			Mstage = stageRef;
			x = xLoc;
			y = yLoc;
			deathTimer.start();
			//myMC=MovieClip(this.parent.getChildByName(this.name));
			addEventListener(Event.ENTER_FRAME, loop);
		}

		public function deletePowerup(e:Event) {
			if (killed == false)
			{
				Mstage.powerups.removeChild(this);
				deathTimer.stop();
				deathTimer.reset();
				killed = true;
			}
		}

		function loop(e:Event)
		{
			if (engine.objectsPaused == true)
				deathTimer.stop();
			else
				deathTimer.start();
		}
		
		public function removePowerup() {
			if (killed == false)
			{
				deathTimer.stop();
				Mstage.powerups.removeChild(this);
				killed = true;
			}
		}
	}
}